package com.bango.blackberry;

import net.rim.device.api.system.Branding;
import net.rim.device.api.system.DeviceInfo;

public class BangoConstants
{
	public static final int SDK_TYPE = 2;
	public static final String SDK_VERSION = "1.2.0";

	public static final String POST_RESPONSE_SUCCESS = "OK";

	public static final String ERROR_TAG = "BANGO_INAPP_ANALYTICS";

	public static final String VIDEO_PARAMETERNAME = "BGO_VIDEOTYPE";
	public static final String VIDEO_LIVEPARAMETER = "LIVE";
	public static final String VIDEO_ONDEMANDPARAMETER = "ONDEMAND";

	public static final long POSTDELAY_SESSIONEND = 10000L;

	public static final int WIFI_CONNECTION = -999;

	public static final String UNKNOWN_INFORMATION = "Unknown";

	public static final int ERROR_NONE = 0;
	public static final int ERROR_USER = 1;
	public static final int ERROR_INTERNAL_CRITICAL = -1;
	public static final int ERROR_INTERNAL_WARNING = -2;

	public static final String LOCATION_CELL = "CELL";
	public static final String LOCATION_ASSISTED = "ASSISTED";
	public static final String LOCATION_GPS = "GPS";

	public static final String SETTING_POST_URL = "http://bango.net/AppAnalytics/";
	public static final boolean SETTING_LOGEVENTS = true;
	public static final int SETTING_SESSION_RESUME_PERIOD = 10;
	public static final String SETTING_LOCATION_SOURCE = LOCATION_GPS;
	public static final boolean SETTING_LOCATION_FIND = true;

	public static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";

	// TODO: Are These Required?
	public static final String DEVICE_BUILD_BRAND = Integer.toString(Branding.getVendorId());
	public static final String DEVICE_BUILD_DEVICE = null;
	public static final String DEVICE_BUILD_PRODUCT = null;
	//

	public static final String DEVICE_BUILD_MODEL = DeviceInfo.getDeviceName();
	public static final String DEVICE_BUILD_VERSION = DeviceInfo.getSoftwareVersion();
	public static final String DEVICE_BUILD_ID = DeviceInfo.getPlatformVersion();

	public static final long STORE_KEY = 0x982c06484caa51f1L; // BANGO_STORE_V1.0
																// - Right Click
																// Convert
																// String To
																// Long

	public static final String DATABASE_NAME = "BangoAnalytics.db";
	public static final int DATABASE_VERSION = 1;
	public static final String DATABASE_TABLE_PLACEHOLDER = "$TABLENAME";
	public static final String DATABASE_TABLE_JOINPLACEHOLDER = "$TABLEJOINNAME";
	public static final String DATABASE_PARAMETER1_PLACEHOLDER = "$PARAMETER1";
	public static final String DATABASE_PARAMETER2_PLACEHOLDER = "$PARAMETER2";
	public static final String DATABASE_PARAMETER3_PLACEHOLDER = "$PARAMETER3";
	public static final String DATABASE_PARAMETER4_PLACEHOLDER = "$PARAMETER4";

	public static final String DATABASE_TABLENAMEPREFIX = "InApp";

	public static final String DATABASE_SELECTTABLES = "SELECT name FROM sqlite_master WHERE type = 'table' AND name LIKE '" + DATABASE_TABLENAMEPREFIX + "%'";
	public static final String DATABASE_SELECTPOSTPROFILES = "SELECT _id as profileId, sdkType, sdkVersion, applicationId, applicationType, applicationChannel, applicationVersion, userId, sessionRestartTime, connectionType, isRoaming, String locationSource, locationAltitude, locationLatitude, locationLongitude, locationAccuracy, operator, operatorCountryIso, simOperator, brand, device, model, product, version, buildId, operatorConnectionType FROM [$TABLENAME] WHERE _id != ?";
	public static final String DATABASE_SELECTPOSTEVENTS = "SELECT _id as eventId, profileId, eventName, eventDetail, eventValue, errorId, eventTime, eventLocalTime, connectionType, operatorConnectionType, errorLevel FROM [$TABLENAME] WHERE eventPosted = 0 AND profileId = ?";
	public static final String DATABASE_SELECTPOSTEVENTPARAMETERS = "SELECT _id as eventParameterId, eventId, eventName, eventValue FROM [$TABLENAME] WHERE eventId = ?";

	public static final String DATABASE_UPDATEPROFILELOCATION = "UPDATE [$TABLENAME] SET locationLatitude = $PARAMETER1, locationLongitude = $PARAMETER2, locationAltitude = $PARAMETER3, locationAccuracy = $PARAMETER4 WHERE _id = ";
	public static final String DATABASE_UPDATEPROFILEPOSTED = "UPDATE [$TABLENAME] SET profilePosted = 1 WHERE _id = ";
	public static final String DATABASE_UPDATEEVENTPOSTED = "UPDATE [$TABLENAME] SET eventPosted = 1 WHERE profileId = ";

	public static final String DATABASE_DELETEPROFILE = "DELETE FROM [$TABLENAME] WHERE profilePosted = 1 AND _id = ";
	public static final String DATABASE_DELETEEVENT = "DELETE FROM [$TABLENAME] WHERE eventPosted = 1 AND profileId = ";
	public static final String DATABASE_DELETEEVENTPARAMETER = "DELETE FROM [$TABLENAME] WHERE eventId IN (SELECT _id FROM [$TABLEJOINNAME] WHERE eventPosted = 1 AND profileId = $PARAMETER1)";

	public static final String DATABASE_TABLECREATEPROFILE = "CREATE TABLE IF NOT EXISTS [$TABLENAME] (_id INTEGER PRIMARY KEY, sdkType INTEGER, sdkVersion NUMERIC, applicationId TEXT, applicationType TEXT, applicationChannel TEXT, applicationVersion TEXT, userId TEXT, sessionRestartTime INTEGER, connectionType INTEGER, isRoaming BOOLEAN, locationSource TEXT, locationAltitude NUMERIC, locationLatitude NUMERIC, locationLongitude NUMERIC, locationAccuracy NUMERIC, operator TEXT, operatorCountryIso TEXT, simOperator TEXT, brand TEXT, device TEXT, model TEXT, product TEXT, version TEXT, buildId TEXT, operatorConnectionType INTEGER, profilePosted BOOLEAN)";
	public static final String DATABASE_TABLECREATEEVENT = "CREATE TABLE IF NOT EXISTS [$TABLENAME] (_id INTEGER PRIMARY KEY, profileId INTEGER, eventName TEXT, eventDetail TEXT, eventValue TEXT, errorId TEXT, eventTime DATETIME, eventLocalTime, DATETIME, connectionType INTEGER, operatorConnectionType INTEGER, errorLevel INTEGER, locationLatitude NUMERIC, locationLongitude NUMERIC, locationAccuracy NUMERIC, eventPosted BOOLEAN)";
	public static final String DATABASE_TABLECREATEEVENTPARAMETER = "CREATE TABLE IF NOT EXISTS [$TABLENAME] (_id INTEGER PRIMARY KEY, eventId INTEGER, eventName TEXT, eventValue TEXT)";

	public static final String DATABASE_CREATEPROFILE = "INSERT INTO [$TABLENAME] ('sdkType', 'sdkVersion', 'applicationId', 'applicationType', 'applicationChannel', 'applicationVersion', 'userId', 'sessionRestartTime', 'connectionType', 'isRoaming', 'locationSource', 'locationAltitude', 'locationLatitude', 'locationLongitude', 'locationAccuracy', 'operator', 'operatorCountryIso', 'simOperator', 'brand', 'device', 'model', 'product', 'version', 'buildId', 'operatorConnectionType', 'profilePosted') VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
	public static final String DATABASE_CREATEEVENT = "INSERT INTO [$TABLENAME] ('profileId', 'eventName', 'eventDetail', 'eventValue', 'errorId', 'eventTime', 'eventLocalTime', 'connectionType', 'operatorConnectionType', 'errorLevel', 'eventPosted')VALUES(?,?,?,?,?,?,?,?,?,?,?)";
	public static final String DATABASE_CREATEEVENTPARAMETER = "INSERT INTO [$TABLENAME] ('eventId', 'eventName', 'eventValue') VALUES (?,?,?)";
	public static final String DATABASE_TABLENAMEPROFILE = "InAppProfiles";
	public static final String DATABASE_TABLENAMEEVENT = "InAppEvents";
	public static final String DATABASE_TABLENAMEEVENTPARAMETER = "InAppEventParameters";

	public static final String DATABASE_COLUMN_PROFILEID = "profileId";
	public static final String DATABASE_COLUMN_SDKTYPE = "sdkType";
	public static final String DATABASE_COLUMN_SDKVERSION = "sdkVersion";
	public static final String DATABASE_COLUMN_APPLICATIONID = "applicationId";
	public static final String DATABASE_COLUMN_APPLICATIONTYPE = "applicationType";
	public static final String DATABASE_COLUMN_APPLICATIONCHANNEL = "applicationChannel";
	public static final String DATABASE_COLUMN_APPLICATIONVERSION = "applicationVersion";
	public static final String DATABASE_COLUMN_USERID = "userId";
	public static final String DATABASE_COLUMN_SESSIONRESTARTTIME = "sessionRestartTime";
	public static final String DATABASE_COLUMN_CONNECTIONTYPE = "connectionType";
	public static final String DATABASE_COLUMN_ISROAMING = "isRoaming";
	public static final String DATABASE_COLUMN_LOCATIONSOURCE = "locationSource";
	public static final String DATABASE_COLUMN_LOCATIONALTITUDE = "locationAltitude";
	public static final String DATABASE_COLUMN_LOCATIONLATITUDE = "locationLatitude";
	public static final String DATABASE_COLUMN_LOCATIONLONGITUDE = "locationLongitude";
	public static final String DATABASE_COLUMN_LOCATIONACCURACY = "locationAccuracy";
	public static final String DATABASE_COLUMN_OPERATOR = "operator";
	public static final String DATABASE_COLUMN_OPERATORCOUNTRYISO = "operatorCountryIso";
	public static final String DATABASE_COLUMN_SIMOPERATOR = "simOperator";
	public static final String DATABASE_COLUMN_BRAND = "brand";
	public static final String DATABASE_COLUMN_DEVICE = "device";
	public static final String DATABASE_COLUMN_MODEL = "model";
	public static final String DATABASE_COLUMN_PRODUCT = "product";
	public static final String DATABASE_COLUMN_VERSION = "version";
	public static final String DATABASE_COLUMN_BUILDID = "buildId";
	public static final String DATABASE_COLUMN_OPERATORCONNECTIONTYPE = "operatorConnectionType";
	public static final String DATABASE_COLUMN_EVENTID = "eventId";
	public static final String DATABASE_COLUMN_EVENTNAME = "eventName";
	public static final String DATABASE_COLUMN_EVENTDETAIL = "eventDetail";
	public static final String DATABASE_COLUMN_EVENTVALUE = "eventValue";
	public static final String DATABASE_COLUMN_ERRORID = "errorId";
	public static final String DATABASE_COLUMN_EVENTTIME = "eventTime";
	public static final String DATABASE_COLUMN_EVENTLOCALTIME = "eventLocalTime";
	public static final String DATABASE_COLUMN_ERRORLEVEL = "errorLevel";

}
